#include <linux/module.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/uaccess.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>

static int major;
static struct class *led_class;

static int led_open(struct inode *node, struct file *filp)
{
	printk("led open\n");
	return 0;
}

static int led_write(struct file *filp, const char __user *buf, size_t size, loff_t *off)
{
	printk("led write\n");
	return 1;
}

static int led_release(struct inode *node, struct file *filp)
{
	printk("led release\n");
	return 0;
}


/*
static int led_read(struct file *filp, const char __user *buf, size_t size, loff_t *off)
{
}
*/

static struct file_operations myled_oprs = {
	.owner = THIS_MODULE,
  .open  = led_open,
  .write = led_write,
//.read  = led_read,
  .release = led_release,
};

static int myled_init(void)
{
	major = register_chrdev(0, "myled", &myled_oprs);

	led_class = class_create(THIS_MODULE, "myled");
	device_create(led_class, NULL, MKDEV(major, 0), NULL, "led");

	return 0;
}

static void myled_exit(void)
{
	unregister_chrdev(major, "myled");
	device_destroy(led_class, MKDEV(major, 0));
	class_destroy(led_class);

}

module_init(myled_init);
module_exit(myled_exit);

MODULE_LICENSE("GPL");
